/**
 * 信用卡管理管理初始化
 */
var CreditCardOrder = {
    id: "CreditCardOrderTable",	//表格id
    seItem: null,		//选中的条目
    table: null,
    layerIndex: -1
};
/**
 * 初始化表格的列
 */
CreditCardOrder.initColumn = function () {
    return [
        {field: 'selectItem', radio: true},
        {title: '订单号', field: 'orderid', visible: true, align: 'center', valign: 'middle',width:280},
        {title: '申请完成标识 ', field: 'applyCompleted', visible: false, align: 'center', valign: 'middle'},
        {title: '审核结果标识', field: 'applicationStatus', visible: false, align: 'center', valign: 'middle'},
        {title: '已寄出标识 ', field: 'mailed', visible: false, align: 'center', valign: 'middle'},
        {title: '激活成功标识 ', field: 'activated', visible: false, align: 'center', valign: 'middle'},
        {title: '首刷标识', field: 'firstUsed', visible: false, align: 'center', valign: 'middle'},
        {title: '用户手机号', field: 'phone', visible: true, align: 'center', valign: 'middle',width:95},
        {title: '银行', field: 'bankType', visible: true, align: 'center', valign: 'middle'},
        {title: '订单状态', field: 'currentStatus', visible: true, align: 'center', valign: 'middle'},
        {title: '创建时间', field: 'createTime', visible: false, align: 'center', valign: 'middle'},
        {title: '更新时间', field: 'updateTime', visible: false, align: 'center', valign: 'middle'},
        {title: '用户id', field: 'userid', visible: true, align: 'center', valign: 'middle',width:240},
        {title: '邀请人id', field: 'parentUserid', visible: true, align: 'center', valign: 'middle',width:240},
        {title: '邀请人上级', field: 'rootUserid', visible: true, align: 'center', valign: 'middle',width:240},
        {title: '上级的邀请码', field: 'regCode', visible: false, align: 'center', valign: 'middle'},
        {title: '订单状态 ', field: 'status', visible: false, align: 'center', valign: 'middle'},
        {title: '信用卡激活奖励', field: 'reward1', visible: false, align: 'center', valign: 'middle'},
        {title: '信用卡首刷奖励', field: 'reward2', visible: false, align: 'center', valign: 'middle'},
        {title: '用户名', field: 'userName', visible: true, align: 'center', valign: 'middle'},
        {title: '本人奖励', field: 'useridReward', visible: true, align: 'center', valign: 'middle'},
        {title: '上级奖励', field: 'parentUseridReward', visible: true, align: 'center', valign: 'middle'},
        {title: '上上级奖励', field: 'rootUseridReward', visible: true, align: 'center', valign: 'middle'},
        {title: '币种', field: 'currency', visible: false, align: 'center', valign: 'middle',width:50},
        {title: '新卡', field: 'isNew', visible: true, align: 'center', valign: 'middle',width:50}
    ];
};
/**
 * 检查是否选中
 */
CreditCardOrder.check = function () {
    var selected = $('#' + this.id).bootstrapTable('getSelections');
    if(selected.length == 0){
        Feng.info("请先选中表格中的某一记录！");
        return false;
    }else{
        CreditCardOrder.seItem = selected[0];
        return true;
    }
};

/**
 * 点击添加信用卡管理
 */
CreditCardOrder.openAddCreditCardOrder = function () {

    Feng.alert("添加功能暂时关闭");
    return ;
    var index = layer.open({
        type: 2,
        title: '添加信用卡管理',
        area: ['800px', '420px'], //宽高
        fix: false, //不固定
        maxmin: true,
        content: Feng.ctxPath + '/creditCardOrder/creditCardOrder_add'
    });
    this.layerIndex = index;
};

/**
 * 打开查看信用卡管理详情
 */
CreditCardOrder.openCreditCardOrderDetail = function () {
    if (this.check()) {
        var index = layer.open({
            type: 2,
            title: '信用卡管理详情',
            area: ['800px', '420px'], //宽高
            fix: false, //不固定
            maxmin: true,
            content: Feng.ctxPath + '/creditCardOrder/creditCardOrder_update/' + CreditCardOrder.seItem.id
        });
        this.layerIndex = index;
    }
};

/**
 * 删除信用卡管理
 */
CreditCardOrder.delete = function () {
    Feng.alert("删除功能暂时关闭");
    return ;
    if (this.check()) {
        var ajax = new $ax(Feng.ctxPath + "/creditCardOrder/delete", function (data) {
            Feng.success("删除成功!");
            CreditCardOrder.table.refresh();
        }, function (data) {
            Feng.error("删除失败!" + data.responseJSON.message + "!");
        });
        ajax.set("creditCardOrderId",this.seItem.id);
        ajax.start();
    }
};

/**
 * 查询信用卡管理列表
 */
CreditCardOrder.search = function () {
    var queryData = {};
    queryData['condition'] = $("#condition").val();
    CreditCardOrder.table.refresh({query: queryData});
};

$(function () {
    var defaultColunms = CreditCardOrder.initColumn();
    var table = new BSTable(CreditCardOrder.id, "/creditCardOrder/list", defaultColunms);
    table.setPaginationType("client");
    CreditCardOrder.table = table.init();
});
